<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>离心管理</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
	<div class="demoTable" style="padding:10px 0 0 15px">
    	
    	<div class="layui-inline">
        	<input class="layui-input" placeholder="请输入膜管编号" name="keyWord" id="keyWord" autocomplete="off">
    	</div> &nbsp; &nbsp; &nbsp; &nbsp;
    	<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
	</div>
	
	
	<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">撤销</a>
</script>
              
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>

<script>
layui.use(['table','layer','upload','form'], function(){
	var laydate = layui.laydate;
	var table = layui.table;
	var layer = layui.layer;
    var form = layui.form;
    
  //执行一个laydate实例
	laydate.render({
		elem: '#createTime', //指定元素
		type: 'date'
	});
  
	var $ = layui.jquery, active = {
			reload:function () {
				var keyWord = $("#keyWord").val();
				table.reload('contenttable',{
					method:'get',
					where:{
						ctube: keyWord
					}
					,page: {
	                    curr: 1
	                }
				}); 
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/centrifugal/selectcentrifugalList.do'
	    //,toolbar: '#toolbarDemo'
	    ,title: '离心管理'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,request: {   //如果无需自定义请求参数，可不加该参数
            pageName: 'page' //页码的参数名称，默认：page
            ,limitName: 'rows' //每页数据量的参数名，默认：limit
        }
        ,response: {   //如果无需自定义数据响应名称，可不加该参数
            countName: 'total' //规定数据总数的字段名称，默认：count
            ,dataName: 'rows' //规定数据列表的字段名称，默认：data
        }
	    ,cols: [[
	    	{
	    	/* 	type: 'checkbox',
	    		fixed: 'left'
	    	}, { */
            	field:'id',
            	title:'序号', 
            	//sort: true,
            	type:'numbers',
            	//align:'center'
	    	},{
	    		field:'cid', 
	    		title:'离心id',
	    		hide:true,
	    	},{
	    		field:'ctube',
	    		title:'膜管编号'
	    	},{
	    		field:'ccode',
	    		title:'离心机编号'
	    	},{
	    		field:'coperator', 
	    		title:'操作人'
	    	},{
	    		field:'ctime', 
	    		title:'操作时间'
	    	},{
	    		fixed: 'right',
	    		title:'操作',
	    		toolbar: '#barDemo'
	    	}
	    ]]
	    ,page: true
	});
  
  
	//监听行工具事件
	table.on('tool(test)', function(obj){
		var data = obj.data;
		if(obj.event === 'del'){
			layer.confirm('确定撤销吗？', function(index){
		    var id = data.mbsid;
		    var ccode = data.ccode;
		    var ctube = data.ctube;
		    $.ajax({
		    	type:'post',
		    	url:'${pageContext.request.contextPath }/revoke/centrifugal.do',
		    	data:{"cid":id,"ccode":ccode,"ctube":ctube},
		    	dataType : "json",
		    	success:function(data){
		    		if(data>0){
		    			toastr.success("撤销成功！");
		    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},1000);
		    		}else if(data==-1){
		    			toastr.warning("已在下一工位操作，不能撤销！");
		    		}else if(data==-2){
		    			toastr.warning("已经撤销！");
		    			setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},1000);
		    		}else{
		    			toastr.warning("撤销失败！");
		    		}
		    	}
		    		
		    })
		    layer.close(index);
		  });
		} 
	});
});

toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
</script>
</body>
</html>